package Verktoy;

import javax.faces.bean.ManagedBean;

/**
 * Klasse som konverterer tekst til 1337 språk
 * @author Gruppe1
 */
@ManagedBean(name="1337")

public class Converter1337 {

    private String [][] leet = {
        {"a","4"},
        {"b","8"},
        {"c","("},
        {"d","Ð"},
        {"e","3"},
        {"f","|="},
        {"g","9"},
        {"h","|-|"},
        {"i","I"},
        {"j","j"},
        {"k","|{"},
        {"l","1"},
        {"m","|^|^|"},
        {"n","/|/"},
        {"o","0"},
        {"p","|*"},
        {"q","*|"},
        {"r","|2"},
        {"s","5"},
        {"t","7"},
        {"u","µ"},
        {"v","v"},
        {"w","|_|_|"},
        {"x","><"},
        {"y","¥"},
        {"z","2"}};
    /**
     * Metode som konverterer en tekststreng ihht 1337speak
     * @param text String som skal konverteres
     * @return 
     */
    public String convertTo1337(String text){
        text = text.toLowerCase();
        String leetSpeek = "";
        for(int i = 0 ; i < text.length() ; i++){
            leetSpeek += finnEqu(""+text.charAt(i));
        }
        return leetSpeek;
    }
    private String finnEqu(String bokst){
        for(int i = 0 ; i < leet.length ; i++){
            if(leet[i][0].equals(bokst)) return leet[i][1];
        }
        return bokst;
    }
    public static void main(String [] args){
        String test = "Register more results";
        Converter1337 c = new Converter1337();
        System.out.println(c.convertTo1337(test));
    }
}
